
#ifndef MASS_SPRING_ANIMATION_H
#define MASS_SPRING_ANIMATION_H

#include <QtGui/QMainWindow>
#include "ui_Mass_Spring_Animation.h"

/* Sx Library Includes */
#include <sxQOpenGL_Viewport.h>
#include <sxOpenGL_Context.h>
#include <sxOpenGL_Canvas.h>
#include <sxOpenGL_PickingController.h>
#include <sxMassSpringMesh.h>
#include <sxMassSpringSimulation.h>
#include <sxMSS_ReplayEditController.h>
#include <sxOBJ_VegaMassSpringMeshStorage.h>
#include <sxFixedTimelineCurveController.h>

/* Sx OpenGL */
using Sx::QtInterface::QOpenGL_Viewport;
using Sx::OpenGL::Graphics::Contexts::OpenGL_Context;
using Sx::OpenGL::Interface::OpenGL_Canvas;
using Sx::OpenGL::Graphics::Picking::OpenGL_PickingController;

/* Sx Mass-Spring Simulation */
using Sx::Simulation::Objects::MassSpringMesh;
using Sx::Simulation::Simulations::MassSpringSimulation;

/* Sx Mass-Spring Recording */
using Sx::Multimedia::Interface::FixedTimelineCurveController;
using Sx::Simulation::Interface::MSS_ReplayEditController;
using Sx::Simulation::Recording::MassSpringSimulationRecording;
using Sx::Simulation::Recording::MassSpringSimulationRecorder;
using Sx::Simulation::Interface::MassSpringSimulationReplayController;

/* Sx OBJ_Vega Storage */
using Sx::Vega::Storage::OBJ_VegaMassSpringMeshStorage;

class Mass_Spring_Animation : public QMainWindow {
	Q_OBJECT

public:
	Mass_Spring_Animation(QWidget *parent = 0, Qt::WFlags flags = 0);
	~Mass_Spring_Animation();

public slots:
	void onStartRecording();
	void onStopRecording();
	void onPlay();
	void onPause();
	void onResetTime();
	void onTimeIncrement();
	void onTimeDecrement();
	void onApplyForceCurve();
	void onGeneratePreview();
	void onClearPreview();

private:
	Ui::Mass_Spring_AnimationClass ui;

	/* OpenGL Viewports */
	QOpenGL_Viewport* viewport_Simulation;
	QOpenGL_Viewport* viewport_CurveEditor;

	/* OpenGL Context */
	std::shared_ptr<OpenGL_Context> openglContext;
	std::shared_ptr<OpenGL_Canvas> openglCanvas;
	std::shared_ptr<OpenGL_PickingController> openglPickingController;

	/* Mass Spring System */
	std::shared_ptr<MassSpringSimulation> massSpringSimulation;

	/* MassSpringMesh Demo Objects */
	std::shared_ptr<OBJ_VegaMassSpringMeshStorage> objStorage;
	std::shared_ptr<MassSpringMesh> ground;
	std::shared_ptr<MassSpringMesh> object1;
	std::shared_ptr<MassSpringMesh> object2;
	std::shared_ptr<MassSpringMesh> object3;

	/* Controllers */
	std::shared_ptr<FixedTimelineCurveController> curveEditor;
	std::shared_ptr<MSS_ReplayEditController> mssEditController;

	/* MassSpring Simulation Recording */
	std::shared_ptr<MassSpringSimulationRecording> testRecording;
	std::shared_ptr<MassSpringSimulationRecorder> mssRecorder;
	std::shared_ptr<MassSpringSimulationReplayController> replayController;
};

#endif
